package list;

import java.util.Collection;

/**
 *
 * @author Shimu
 * @date 10-Aug-2012
 */
public abstract class FixedList<T> extends IndexableList<T> {
  
    protected FixedList(int size) {
        super(size);
    }

    @Override
    public abstract T get(int index);

    @Override
    public abstract T set(int index, T element);

    @Override
    public abstract FixedList<T> subList(int fromIndex, int toIndex);
    
    // ============= These Methods Are Unsupported =============
    // These are all optional operation in List interface
    /**
     * Unsupported, cannot add elements to a fixed size list.
     * 
     * @throws UnsupportedOperationException
     * @param e
     * @return 
     */
    @Override
    @Deprecated
    public final void add(int index, T element) {
        throw new UnsupportedOperationException("Cannot add elements"
                + " to a fixed size list!");
    }

    /**
     * Unsupported, cannot add elements to a fixed size list.
     * 
     * @throws UnsupportedOperationException
     * @param e
     * @return 
     */
    @Override
    @Deprecated
    public final boolean add(Object e) {
        throw new UnsupportedOperationException("Cannot add elements"
                + " to a fixed size list!");
    }

    /**
     * Unsupported, cannot add elements to a fixed size list.
     * 
     * @throws UnsupportedOperationException
     * @param c
     * @return 
     */
    @Override
    @Deprecated
    public final boolean addAll(Collection c) {
        throw new UnsupportedOperationException("Cannot add elements"
                + " to a fixed size list!");
    }

    /**
     * Unsupported, cannot add elements to a fixed size list.
     * 
     * @throws UnsupportedOperationException
     * @param index
     * @param c
     * @return 
     */
    @Override
    @Deprecated
    public final boolean addAll(int index, Collection c) {
        throw new UnsupportedOperationException("Cannot add elements"
                + " to a fixed size list!");
    }

    /**
     * Unsupported, cannot add elements to a fixed size list.
     * 
     * @throws UnsupportedOperationException
     * @param o
     * @return 
     */
    @Override
    @Deprecated
    public final boolean remove(Object o) {
        throw new UnsupportedOperationException("Cannot remove elements"
                + " from a fixed size list!");
    }

    /**
     * Unsupported, cannot add elements to a fixed size list.
     * 
     * @throws UnsupportedOperationException
     * @param index
     * @return 
     */
    @Override
    @Deprecated
    public final T remove(int index) {
        throw new UnsupportedOperationException("Cannot remove elements"
                + " from a fixed size list!");
    }

    /**
     * Unsupported, cannot add elements to a fixed size list.
     * 
     * @throws UnsupportedOperationException
     * @param c
     * @return 
     */
    @Override
    @Deprecated
    public final boolean removeAll(Collection c) {
        throw new UnsupportedOperationException("Cannot remove elements"
                + " from a fixed size list!");
    }

    /**
     * Unsupported, cannot add elements to a fixed size list.
     * 
     * @throws UnsupportedOperationException
     * @param c
     * @return 
     */
    @Override
    @Deprecated
    public final boolean retainAll(Collection c) {
        throw new UnsupportedOperationException("Cannot remove elements"
                + " from a fixed size list!");
    }

    /**
     * Unsupported, cannot add elements to a fixed size list.
     * 
     * @throws UnsupportedOperationException
     */
    @Override
    @Deprecated
    public final void clear() {
        throw new UnsupportedOperationException("Cannot remove elements"
                + " from a fixed size list!");
    }
}
